/*
Copyright(c) 2008 Jari Kemppinen <jari@viddem.com>

This example was built upon the PureMVC Framework by Cliff Hall.
http://www.puremvc.org
This example uses the Java PureMVC Framework Version 0.2

Please contribute to the PureMVC community.

License
-------
Your reuse is governed by the Creative Commons Attribution 3.0 license.
 */

package org.lbroussal.client.view.components;

import org.lbroussal.client.model.ItemDataProxy;
import org.lbroussal.client.model.vo.ItemDataVO;
import org.lbroussal.client.view.MainScreenMediator;

import com.google.gwt.user.client.ui.*;

public class MainScreen extends Composite {

    private MainScreenMediator mediator;

    private ItemDataProxy itemProxy;

    private VerticalPanel dataContentPanel;

    public MainScreen(MainScreenMediator mediator, ItemDataProxy itemProxy) {
        this.mediator = mediator;
        this.itemProxy = itemProxy;
        buildUI();
        initWidget(dataContentPanel);
        setData();
    }

    /**
     * 
     */
    private void setData() {
        dataContentPanel.add(new HTML("<font color='blue'>NOw, It's your turn to play with PureMVC4GWT!  Enjoy :)</font>"));
        for (ItemDataVO item : itemProxy.getData().values()) {
            dataContentPanel.add(new Label("DataObject coming from MVC Proxy :" + item.toString()));
        }
        dataContentPanel.add(new HTML(
                "<font color='blue'>Portage of PureMVC on GWT and this simple LoginDemo are presented by Luciano Broussal</font>"));
        dataContentPanel.add(new HTML(
                "<font color='blue'>Acknowledgement to Cliff who is the PureMVC owner and his simple and powerful MVC framework.</font>"));
        Button logout = new Button("Logout");
        dataContentPanel.add(logout);
        logout.addClickListener(new ClickListener() {
            public void onClick(Widget sender) {
                MainScreen.this.mediator.LOGOUT();
            }

        });

    }

    private void buildUI() {
        buildMenu();
    }

    private void buildMenu() {

        dataContentPanel = new VerticalPanel();
        dataContentPanel.setVerticalAlignment(HasVerticalAlignment.ALIGN_TOP);
        dataContentPanel.setSpacing(3);

    }
}
